<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Extract information from result</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.ldap-parse-reference.html">« ldap_parse_reference</a></li>
      <li style="float: right;"><a href="function.ldap-read.html">ldap_read »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.ldap.html">LDAP 函数</a></li>
    <li>Extract information from result</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.ldap-parse-result" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ldap_parse_result</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.5, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">ldap_parse_result</span> &mdash; <span class="dc-title">Extract information from result</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.ldap-parse-result-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>ldap_parse_result</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="class.ldap-connection.html" class="type LDAP\Connection">LDAP\Connection</a></span> <code class="parameter">$ldap</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="class.ldap-result.html" class="type LDAP\Result">LDAP\Result</a></span> <code class="parameter">$result</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">int</span> <code class="parameter reference">&$error_code</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">string</span> <code class="parameter reference">&$matched_dn</code><span class="initializer"> = <strong><code>null</code></strong></span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">string</span> <code class="parameter reference">&$error_message</code><span class="initializer"> = <strong><code>null</code></strong></span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">array</span> <code class="parameter reference">&$referrals</code><span class="initializer"> = <strong><code>null</code></strong></span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">array</span> <code class="parameter reference">&$controls</code><span class="initializer"> = <strong><code>null</code></strong></span></span><br>): <span class="type">bool</span></div>

  <p class="para rdfs-comment">
   Parses an LDAP search result.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.ldap-parse-result-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">ldap</code></dt>

     <dd>

      <p class="para">
       通过 <span class="function"><a href="function.ldap-connect.html" class="function">ldap_connect()</a></span> 返回的 <span class="classname"><a href="class.ldap-connection.html" class="classname">LDAP\Connection</a></span> 实例。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">result</code></dt>

     <dd>

      <p class="para">
       通过 <span class="function"><a href="function.ldap-list.html" class="function">ldap_list()</a></span> 或者 <span class="function"><a href="function.ldap-search.html" class="function">ldap_search()</a></span> 返回的 <span class="classname"><a href="class.ldap-result.html" class="classname">LDAP\Result</a></span> 实例。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">error_code</code></dt>

     <dd>

      <p class="para">
       A reference to a variable that will be set to the LDAP error code in
       the result, or <code class="literal">0</code> if no error occurred.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">matched_dn</code></dt>

     <dd>

      <p class="para">
       A reference to a variable that will be set to a matched DN if one was
       recognised within the request, otherwise it will be set to <strong><code>null</code></strong>.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">error_message</code></dt>

     <dd>

      <p class="para">
       A reference to a variable that will be set to the LDAP error message in
       the result, or an empty string if no error occurred.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">referrals</code></dt>

     <dd>

      <p class="para">
       A reference to a variable that will be set to an <span class="type">array</span> set
       to all of the referral strings in the result, or an empty array if no
       referrals were returned.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">controls</code></dt>

     <dd>

      <p class="para">
       An <span class="type">array</span> of LDAP Controls which have been sent with the response.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.ldap-parse-result-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>true</code></strong>， 或者在失败时返回 <strong><code>false</code></strong>。
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.ldap-parse-result-changelog">
  <h3 class="title">更新日志</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>版本</th>
       <th>说明</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
 <td>8.1.0</td>
 <td>
  现在 <code class="parameter">ldap</code> 参数接受 <span class="classname"><a href="class.ldap-connection.html" class="classname">LDAP\Connection</a></span>
  实例，之前接受 <a href="language.types.resource.html" class="link">资源(resource)</a>。
 </td>
</tr>

      <tr>
 <td>8.1.0</td>
 <td>
  The <code class="parameter">result</code> parameter expects an <span class="classname"><a href="class.ldap-result.html" class="classname">LDAP\Result</a></span>
  instance now; previously, a <a href="language.types.resource.html" class="link">资源(resource)</a> was expected.
 </td>
</tr>

      <tr>
       <td>7.3.0</td>
       <td>
        Support for <code class="parameter">controls</code> added
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.ldap-parse-result-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-4353">
    <p><strong>示例 #1 <span class="function"><strong>ldap_parse_result()</strong></span> example</strong></p>
    <div class="example-contents">
     <div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$result&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ldap_search</span><span style="color: #007700">(</span><span style="color: #0000BB">$ldap</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"cn=userref,dc=my-domain,dc=com"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"(cn=user*)"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$errcode&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$dn&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$errmsg&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$refs&nbsp;</span><span style="color: #007700">=&nbsp;&nbsp;</span><span style="color: #0000BB">null</span><span style="color: #007700">;<br />if&nbsp;(</span><span style="color: #0000BB">ldap_parse_result</span><span style="color: #007700">(</span><span style="color: #0000BB">$ldap</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$result</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$errcode</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$dn</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$errmsg</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$refs</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;do&nbsp;something&nbsp;with&nbsp;$errcode,&nbsp;$dn,&nbsp;$errmsg&nbsp;and&nbsp;$refs<br /></span><span style="color: #007700">}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


</div></div></div></body></html>